package com.lb.shopguide.adapter;

import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.lb.shopguide.R;
import com.lb.shopguide.constants.AppConstant;
import com.lb.shopguide.entity.home.HomeOrderUpdateBean;
import com.lb.shopguide.entity.shop.StaffBean;
import com.lb.shopguide.entity.shop.StoreBean;
import com.lb.shopguide.util.pic.ImageLoaderUtils;

import java.util.List;

/**
 * Created by kang on 2018/1/2.
 */

public class AdapterStaff extends BaseQuickAdapter<StaffBean, BaseViewHolder> {
    public AdapterStaff(int layoutResId, @Nullable List<StaffBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, final StaffBean item) {
        View view = helper.itemView;

        TextView tvStaffName = view.findViewById(R.id.tv_staff_name);
        TextView tvStaffPosition = view.findViewById(R.id.tv_staff_position);
        TextView tvStaffPhone = view.findViewById(R.id.tv_staff_phone);
        ImageView ivStaffLogo = view.findViewById(R.id.iv_staff_logo);
        TextView tvStaffEdit = view.findViewById(R.id.tv_staff_edit);
        TextView tvStaffQuit = view.findViewById(R.id.tv_staff_quit);
        ImageView ivDial = view.findViewById(R.id.iv_dial);

        ImageLoaderUtils.displayCircle(mContext, ivStaffLogo, item.getStaffHeadPicUrl());
        String title = "";
        if (item.getStaffType() == AppConstant.STAFF_TYPE_MANAGER) {
            title = "店长";
        } else if (item.getStaffType() == AppConstant.STAFF_TYPE_GUIDE) {
            title = "导购";
        }
        tvStaffName.setText(item.getStaffName() + "(" + item.getStaffNickName() + ")");
        tvStaffPosition.setText("职位：" + title);
        tvStaffPhone.setText(item.getMobileNum());

        tvStaffQuit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mOnStaffQuitClickListener.onStaffQuitClick(item);
            }
        });

        tvStaffEdit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mOnStaffQuitClickListener.onStaffEdit(item);
            }
        });

        ivDial.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mOnStaffQuitClickListener.onPhoneClick(item.getMobileNum());
            }
        });
    }

    public interface OnStaffQuitClickListener {
        void onStaffQuitClick(StaffBean bean);

        void onStaffEdit(StaffBean bean);

        void onPhoneClick(String phone);
    }

    private OnStaffQuitClickListener mOnStaffQuitClickListener;

    public void setOnStaffQuitClickListener(OnStaffQuitClickListener listener) {
        mOnStaffQuitClickListener = listener;
    }
}